/* 
* 科技有限公司版权所有（）.
* Copyright (c) 2019,   and/or its affiliates. All rights reserved.
* @Date: 2020.09.01 22:47.
* @Author 
* @Description  项目 - 账号管理
**/
<template>
  <div class="pr-account">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="110px" class="demo-ruleForm" :inline="true">
      <el-form-item label="用户账号：" prop="name">
        <el-input v-model="input" placeholder="请输入用户账号"></el-input>
      </el-form-item>

      <el-form-item label="用户手机号：" prop="name">
        <el-input v-model="input" placeholder="请输入用户手机号"></el-input>
      </el-form-item>

      <el-form-item prop="name">
        <el-button type="primary" size="mini">查询</el-button>
      </el-form-item>
    </el-form>

    <el-button type="primary" size="mini" @click="handleAddClick('add')">新建</el-button>

    <el-table :data="tableData" border class="mt10">
      <el-table-column prop="date" label="账号" width="180"></el-table-column>
      <el-table-column prop="name" label="用户姓名" width="180"></el-table-column>
      <el-table-column prop="address" label="角色名"></el-table-column>

      <el-table-column prop="date" label="状态" width="180"></el-table-column>
      <el-table-column prop="name" label="创建时间" width="180"></el-table-column>
      <el-table-column prop="name" label="更新时间" width="180"></el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click.native.prevent="handleOperaClick(scope.$index, tableData, 'edit')" type="text" size="small">编辑</el-button>
          <el-button @click.native.prevent="handleOperaClick(scope.$index, tableData, 'stop')" type="text" size="small">停用</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 新增 编辑 弹窗 -->
    <el-dialog :title="title" :visible.sync="dialogVisible" width="40%">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">

        <el-form-item label="状态：" prop="region">
          <el-select v-model="ruleForm.region" placeholder="请选择状态">
            <el-option label="启用" value="shanghai"></el-option>
            <el-option label="暂停使用" value="beijing"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="账号：" prop="name">
          <el-input v-model="ruleForm.name" placeholder="请输入账号"></el-input>
        </el-form-item>

        <el-form-item label="密码：" prop="name">
          <el-input v-model="ruleForm.name" placeholder="请输入密码"></el-input>
        </el-form-item>

        <el-form-item label="姓名：" prop="name">
          <el-input v-model="ruleForm.name" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item label="联系人手机号：" prop="name">
          <el-input v-model="ruleForm.name" placeholder="请输入联系人手机号"></el-input>
        </el-form-item>

        <el-form-item label="角色选择：" prop="type">
          <el-checkbox-group v-model="ruleForm.type">
            <el-checkbox label="角色" name="type"></el-checkbox>
            <el-checkbox label="角色" name="type"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: 'systemSet',
  props: {},
  components: {},
  data() {
    return {
      input: '',
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: ' 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: ' 1516 弄'
      }],
      title: '账号新增',
      dialogVisible: false,
      ruleForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择活动区域', trigger: 'change' }
        ],
        date1: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],
        date2: [
          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        ],
        type: [
          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
        ],
        resource: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        desc: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {},
  created() { },
  mounted() { },
  methods: {
    /**
     *@Description
     *@Param
     *@Return 账号 新增.
     **/
    handleAddClick() {
      this.title = '新增账号'
      this.dialogVisible = true
    },
    /**
     *@Description
     *@Param
     *@Return 操作项 - 编辑 事件监听.
     **/
    handleOperaClick(index, data, type) {
      if (type === 'edit') {
        this.title = '编辑账号'
        this.dialogVisible = true
      }
    }
  }
}

</script>
<style lang="scss" scoped="scoped">
.pr-account {
  border: 1px solid red;
}
// 新增 编辑 区域 表单margin 重置
::v-deep .el-dialog__body {
  padding: 10px 20px;
}
::v-deep .el-form-item {
  margin-bottom: 10px;
}
</style>
